﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.Library;
using System.Data;
using IHISCETeim.BLL;

namespace IHISCETeim.Web.AgentSys.VipMgr
{
    public partial class VIPCustomerExchangeList : EasyUIPageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.VIP积分兑换_回访, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "VIPCustomerExchangeList";
            }
        }

        #region 属性 (查询条件)

        /// <summary>
        /// 排序字段 值为 id
        /// </summary>
        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "CustExID" : base.orderField;
            }
        }
        /// <summary>
        ///  排序方式 desc或 asc
        /// </summary>
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "DESC" : base.orderDirection;
            }
        }


        protected override string SQLSort
        {
            get
            {
                return (orderField + " " + orderDirection);
            }
        }

       
        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string RealName
        {
            get
            {
                return GetRequestValue<string>("RealName", "");

            }
        }

        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string Tel
        {
            get
            {
                return GetRequestValue<string>("Tel", "");

            }
        }
        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string VIPCardNum
        {
            get
            {
                return GetRequestValue<string>("VIPCardNum", "");

            }
        }
        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string AgentName
        {
            get
            {
                return GetRequestValue<string>("AgentName", "");
            }
        }

        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.等于)]
        public string UserId
        {
            get
            {
                if (User.UserType == 2)
                    return base.User.UserId.ToString();
                else
                    return "";
            }
        }

        #endregion

        protected override string query()
        {
            string sqlwhere = QueryFiledHelper.GetSqlWhere(this);
            DataTable dts = VIPCustomerExchangeController.GetPagination(sqlwhere, pageNum, numPerPage, SQLSort, ref TotalCount);
            return ToDataGridJson(dts, TotalCount, null).ToString();
        }

        protected override string delrow()
        {
            if (base.User.UserType != 1)
                return "";

            int id = GetRequestValue<int>("CustExID", 0);
            bool r = VIPCustomerExchangeController.Delete(id);
            if (r)
                SuccessJson("已成功删除", this.DWZRef);
            else
                ErrorJson("删除失败");

            return "";
        }
    }
}